package com.fangyi.yunmusic.controller;

import com.fangyi.yunmusic.pojo.front.end.FEArtist;
import com.fangyi.yunmusic.service.ArtistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ArtistController {
    @Autowired
    private ArtistService artistService;

    @GetMapping("/artist/getByUser")
    public Object getArtistDetailByUserId(String userId) {
        return artistService.getArtistVOByUserId(userId);
    }

    /**
     * 获取歌手详情
     * @param artistId
     * @return
     */
    @GetMapping("/artist/detail")
    public Object getArtistDetail(String artistId){
        return artistService.selectArtistDetailVO(artistId);
    }

    /**
     * 获取歌手分页
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/artist")
    public Object getPaginationArtist(Integer page,Integer pageSize){
        return artistService.selectArtistVO(page,pageSize);
    }

    /**
     * 新增歌手
     * @param userId
     * @param name
     * @param description
     * @return
     */
    @PostMapping("/artist/add")
    public Object addArtist(String userId, String name,String description){
        artistService.insertArtist(userId,new FEArtist(name,description));
        return "OK";
    }

    /**
     * 删除歌手
     * @param artistId
     * @return
     */
    @PostMapping("/artist/delete")
    public Object deleteArtist(String artistId){
        artistService.deleteArtist(artistId);
        return "OK";
    }
}
